package com.fanfanwang.ffw.app.ui.login;

import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.util.Date;
import java.util.LinkedHashMap;

import org.json.JSONException;

import com.fanfanwang.ffw.app.AppContext;
import com.fanfanwang.ffw.app.AppManager;
import com.fanfanwang.ffw.app.R;
import com.fanfanwang.ffw.app.net.WebServiceHelper;
import com.fanfanwang.ffw.app.widget.CommonTitleBar;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Intent;
import android.os.Bundle;
import android.os.CountDownTimer;
import android.text.TextUtils;
import android.text.method.LinkMovementMethod;
import android.text.util.Linkify;
import android.view.View;
import android.view.View.OnClickListener;
import android.webkit.WebView;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;
/**注册协议*/
@SuppressLint("SetJavaScriptEnabled") public class RegisterAgreementAct extends com.fanfanwang.ffw.app.base.BaseActivity {

	private CommonTitleBar commonTitleBar;
	private Activity mAct;
	private Intent mIntent;
	private WebView webView;
	/**
	 * 网络错误布局layout
	 */
	private LinearLayout llNetError;
	/**
	 * 网络错误显示图片
	 */
	private ImageView ivNetErrorReload;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		initView();
		initData();
		AppManager.getAppManager().addActivity(this);
		setListener();
	}

	@Override
	public void initData() {
		commonTitleBar.setCenterText(getString(R.string.reg_agreement));
		commonTitleBar.setReturnVisible();
		webView.getSettings().setJavaScriptEnabled(true);
		if(AppContext.instance.isNetworkConnected()){
			//网络可用加载数据
			llNetError.setVisibility(View.GONE);
			webView.loadUrl(WebServiceHelper.httpXieYiString);
		} else {
			//网络不可用显示网络错误页面
			llNetError.setVisibility(View.VISIBLE);
		}

	}
	@Override
	protected void initView() {
		// TODO Auto-generated method stub
		setContentView(R.layout.activity_register_agreement);
		mAct = this;
		commonTitleBar = (CommonTitleBar) findViewById(R.id.common_titlebar);
		webView=(WebView)findViewById(R.id.agreement_webView);
		llNetError = (LinearLayout)findViewById(R.id.llNetError);
		ivNetErrorReload = (ImageView)findViewById(R.id.ivNetErrorReload);
	}
	@Override
	protected void setListener() {
		// TODO Auto-generated method stub
		commonTitleBar.setToolBarReturnOnclickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				finish();
			}
		});
		ivNetErrorReload.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				if(AppContext.instance.isNetworkConnected()){
					//网络可用加载数据
					llNetError.setVisibility(View.GONE);
					webView.loadUrl(WebServiceHelper.httpXieYiString);
				} else {
					//网络不可用显示网络错误页面
					llNetError.setVisibility(View.VISIBLE);
				}
			}
		});

	}

}
